package com.weixing.mall.core.utils;

import com.weixing.mall.core.support.SpringContextHolder;
import org.springframework.core.env.AbstractEnvironment;
import org.springframework.core.env.Environment;

/**
 * @ClassName EnvUtil
 * @Description
 * @Author Small
 * @Date 2020/1/18 14:35
 * @Version 1.0
 **/
public class EnvUtil {

    private static final String PROFILE_DEV = "dev";
    private static final String PROFILE_PRO = "pro";

    private static Environment env;

    static {
        env = SpringContextHolder.getBean(AbstractEnvironment.class);
    }

    /**
     * 判断当前环境是否是开发环境
     * @return
     */
    public static boolean isDev() {
        return PROFILE_DEV.equals(env.getProperty("spring.profiles.active"));
    }


    /**
     * 判断当前环境是否是开发环境
     * @return
     */
    public static boolean isPro() {
        return PROFILE_PRO.equals(env.getProperty("spring.profiles.active"));
    }
}
